/**
 * 插件功能：从 src/views 目录自动生成文件路由
 */
import type { App } from 'vue';
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router';
import { createRoutes, createGuard } from './guards';

import basicRoutes from 'virtual:generated-pages';
const routes = createRoutes(basicRoutes);

/* @__PURE__ */
console.log('项目路由组', routes);

export const router = createRouter({
    history: import.meta.env.VITE_HTTP_HASH === true ? createWebHashHistory() : createWebHistory(import.meta.env.VITE_APP_BASE_URL || '/'),
    routes
})

export default async (app: App) => {
    app.use(router)
    createGuard(router)
    await router.isReady()
}